package com.ruoyi.framework.interceptor;


import com.ruoyi.user.domain.User;

public class UserContext {

    static final ThreadLocal<User> CTX = new ThreadLocal<>();

    private UserContext(User user) {
        CTX.set(user);
    }

    public static UserContext setUser(User user) {
        return new UserContext(user);
    }

    public static User currentUser() {
        return CTX.get();
    }


    public static void close() {
        CTX.remove();
    }
}
